package info.empathymobile.forecastmethods;

public class SeasonalNaive implements ForecastMethod {

	public static final String NAME = "Seasonal Naïve";
	public static final int VERSION = 3;

	@Override
	public String getName() {
		return NAME;
	}
	@Override
	public int getVersion() {
		return VERSION;
	}
	
	//SEASONAL NAIVE { Forecast is equal the last same season value }
	//Y(t+h) = Y(t+h−{[(h−1)/m]+1}m)
	//Yt = actual period
	//m= seasonal period
	//h = horizon
	@Override
	public int[] doForecasting(int[] timeSeries, int horizon) {
		//Variables
		int m = 7;
		int t = timeSeries.length-horizon;
		
		for (int h = 1; h <= horizon; h++) {
			int ft = Math.abs(t+h-(((h-1)/m)+1)*m);
			
			//Y(t+h)        = Y(t+h−{[(h−1)/m]+1}m)
			timeSeries[t+h-1] = timeSeries[ft-1];
		}
		return timeSeries;
	}
}
